/**
 * 
 */
package com.googlecode.wmlynar.gwtbeans.gen;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintStream;

/**
 * @author Wojciech Mlynarczyk (woj)
 * 
 */
public class FileDestination {

    public void write(final String className, final String packageName,
            final String targetDirectory, final String content) throws IOException {

        final String dir = targetDirectory + "/" + packageName.replace(".", "/");
        new File(dir).mkdirs();

        final FileOutputStream fos = new FileOutputStream(dir + "/" + className + ".java");
        final PrintStream ps = new PrintStream(fos);
        ps.print(content);
        ps.close();
        fos.close();
    }

}
